#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define Maxsize 32
char array[13];

typedef struct
{
    int data[Maxsize];
    int length;
} IP;

void append(IP &ip, char ch)
{
    ip.data[ip.length++] = ch;
}

IP addDot(IP ip)
{
    append(ip, '.');
    return ip;
}

void devideString(char *s, int len, IP ip, int start, int part)
{

    if (start <= len)
    {
        if (start == len && part == 4)
        {
            for (int i = 0; i < ip.length - 1; i++)

                printf("%c", ip.data[i]);
            printf("\n");
        }
    }
    int num = 0;
    for (int i = start; i < len && i < start + 3; i++)
    {
        num = num * 10 + (s[i] - '0');
        if (num <= 255)
        {
            append(ip, s[i]);
            devideString(s, len, addDot(ip), i + 1, part + 1);
        }
        if (num == 0)
            break;
    }
}

int main()
{
    printf("请输入IP地址：\n");
    scanf("%s", array);
    int len = strlen(array);
    IP ip;
    ip.length = 0;
    printf("恢复的IP地址为：\n");
    devideString(array, len, ip, 0, 0);
    return 0;
}